import { Body, Controller, Get, Param, Put, Query } from '@nestjs/common';
import { StudentService } from './student.service';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import Student from 'src/entities/student.entity';
import { FindStudentDto, UpdateStudentDto } from './student.dto';

@ApiTags('学生管理')
@ApiBearerAuth()
@Controller('student')
export class StudentController {
  constructor(private studentService: StudentService) {}

  @Get('list')
  @ApiOperation({ summary: '获取学生列表' })
  async getStudentList(@Query() query: FindStudentDto) {
    return await this.studentService.find(query);
  }

  @Get('info/:id')
  @ApiOperation({ summary: '获取学生信息' })
  async getStudentInfo(@Param('id') id: string): Promise<Student> {
    return this.studentService.info(id);
  }

  // @Get('detail/:id')
  // @ApiOperation({ summary: '获取学生信息详细' })
  // async getStudentDetail(@Param('id') id: string) {
  //   return this.studentService.detail(id);
  // }

  @Put('update')
  @ApiOperation({ summary: '更新学生信息' })
  async updateStudentInfo(@Body() updateStudentDto: UpdateStudentDto) {
    return this.studentService.update(updateStudentDto);
  }
}
